﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="EditUser.aspx.cs" Inherits="Cms.Web.UI.Admin.EditUser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" href="/Admin/Css/List.css" type="text/css" />
    <script language="javascript" type="text/javascript" src="Admin/Js/Edit.js"></script>
    <script language="javascript" type="text/javascript">
        //<![CDATA[
        function updatePanels(tab) {
            var pnlProperties = document.getElementById("ctl00_body_pnlProperties");
            var pnlMemberships = document.getElementById("ctl00_body_pnlMemberships");
            pnlProperties.style.display = "none";
            pnlMemberships.style.display = "none";
            switch (tab) {
                case "properties":
                    pnlProperties.style.display = "";
                    break;
                case "memberships":
                    pnlMemberships.style.display = "";
                    break;
            }
        }

        var txtUsername;
        var originalUsername;

        function init() {
            txtUsername = document.getElementById("ctl00_body_txtUsername");
            originalUsername = txtUsername.value;
            initMemberships();
        }

        function initMemberships() {
            cms.Lists.Init("membershipPane", prepareMembershipsPopup);
            cms.Lists.HidePaneOverlays();
        }

        function isDirty() {
            var value = originalUsername == "" ||
	                    originalUsername != txtUsername.value;
            document.getElementById("ctl00_tabs_hidIsDirty").value = value;
            return value;
        }

        function prepareMembershipsPopup(trigger, id, name, e) {
            var popup = document.getElementById("pnlPopup");
            var hlEdit = document.getElementById("hlEdit");
            var userId = document.getElementById("ctl00_tabs_hidEditedUserID").value;
            hlEdit.href = "Admin/EditMembership.aspx?userid=" + userId + "&id=" + id.substring(1);
            document.getElementById("ctl00_body_hidDeleteMembershipID").value = id;
            var tdUserGroup = $(trigger.parentElement.parentElement);
            var tdStartDate = tdUserGroup.next();
            var tdEndDate = tdStartDate.next();
            cms.Lists.CurrentName = name + " (" + tdStartDate.html() + " &mdash; " + tdEndDate.html() + ")";
            cms.Lists.ShowPopup(popup, trigger, "left", 0, 0, true, e);
        }
	    //]]>
	</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="buttons" runat="server">
    <asp:UpdatePanel ID="upnlButtons" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <asp:LinkButton ID="lbSave" runat="server" OnClick="lbSave_Click" CssClass="orangeButton"><span id="lblSave1" runat="server"><span id="lblSave2" runat="server"><img src="Admin/Img/icons/disk.png" alt="" /><span><cms:LocalizedLiteral ID="llSave" runat="server" /></span></span></span></asp:LinkButton>
            <asp:HyperLink ID="hlNewMembership" runat="server" CssClass="orangeButton"><span id="lblNewMenu1" runat="server"><span id="lblNewMenu2" runat="server"><img id="imgNewMenu" runat="server" src="Admin/Img/icons/shield_add.png" alt="" /><span id="lblNewMenu3" runat="server"><cms:LocalizedLiteral ID="llNewMembership" runat="server" /></span></span></span></asp:HyperLink>
            <asp:HyperLink ID="hlCancel" runat="server" NavigateUrl="/Admin/Users.aspx" CssClass="orangeButton"><span><span><img src="Admin/Img/icons/delete.png" alt="" /><span><cms:LocalizedLiteral ID="llCancel" runat="server" /></span></span></span></asp:HyperLink>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="tabs" runat="server">
    <asp:UpdatePanel ID="upnlTabs" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <cms:AdminTabStrip ID="tabStrip" runat="server" SelectedValue="properties" OnChange="tabStrip_Click">
                <cms:AdminTabItem ID="tiProperties" runat="server" value="properties" EnabledImage="Admin/Img/icons/group_gear.png"><cms:LocalizedLiteral ID="llPropertiesTab" runat="server" /></cms:AdminTabItem>
                <cms:AdminTabItem ID="tiMemberships" runat="server" value="memberships" EnabledImage="Admin/Img/icons/shield.png"><cms:LocalizedLiteral ID="llMembershipsTab" runat="server" /></cms:AdminTabItem>
            </cms:AdminTabStrip>
            <input type="hidden" id="hidIsDirty" runat="server" />
            <input type="hidden" id="hidSave" runat="server" />
            <input type="hidden" id="hidEditedUserID" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="body" runat="server">
    <asp:Literal ID="litIcon" runat="server" Visible="false" Text="Admin/Img/Icons/user_edit.png" />
    
    <asp:Panel ID="pnlProperties" runat="server" CssClass="pnlTab">
        <asp:UpdatePanel ID="upnlProperties" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
            <ContentTemplate>
                <table class="editForm">
                    <tr>
                        <td><cms:LocalizedLiteral ID="llUsername" runat="server" />:</td>
                        <td><asp:TextBox ID="txtUsername" runat="server" /></td>
                    </tr>
                    <tr>
                        <td><cms:LocalizedLiteral ID="llPassword" runat="server" />:</td>
                        <td><asp:TextBox ID="txtPassword" runat="server" /></td>
                    </tr>
                    <tr>
                        <td><cms:LocalizedLiteral ID="llEmail" runat="server" />:</td>
                        <td><asp:TextBox ID="txtEmail" runat="server" /></td>
                    </tr>
                    <tr>
                        <td><cms:LocalizedLiteral ID="llFirstname" runat="server" />:</td>
                        <td><asp:TextBox ID="txtFirstname" runat="server" /></td>
                    </tr>
                    <tr>
                        <td><cms:LocalizedLiteral ID="llLastname" runat="server" />:</td>
                        <td><asp:TextBox ID="txtLastname" runat="server" /></td>
                    </tr>
                    <tr>
                        <td><cms:LocalizedLiteral ID="llPhone" runat="server" />:</td>
                        <td><asp:TextBox ID="txtPhone" runat="server" /></td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div class="pnlTabOverlay"></div>
    </asp:Panel>

    <asp:Panel ID="pnlMemberships" runat="server" CssClass="pnlTab">
        <div id="membershipPane" style="position: relative;">
            <asp:UpdatePanel ID="upnlMemberships" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
                <ContentTemplate>
                    <asp:Panel ID="pnlActions" runat="server" />
                    <table class="list" id="tblUsers">
                        <tr>
                            <th><cms:LocalizedLiteral ID="llUserGroupHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llStartDateHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llEndDateHeader" runat="server" /></th>
                            <th><cms:LocalizedLiteral ID="llSystemIdHeader" runat="server" /></th>
                        </tr>
                        <asp:Repeater ID="rpMemberships" runat="server" OnItemDataBound="rpMemberships_ItemDataBound">
                            <ItemTemplate>
                                <tr>
                                    <td><asp:Literal ID="litId" runat="server" /><img src="/Admin/Img/icons/shield.png" alt="Edit" /><span><asp:literal ID="litUserGroup" runat="server" /></span></span></td>
                                    <td><asp:Literal ID="litStartDate" runat="server" /></td>
                                    <td><asp:Literal ID="litEndDate" runat="server" /></td>
                                    <td><asp:Literal ID="litSystemId" runat="server" /></td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                        <tr id="trNoHits" runat="server">
                            <td colspan="2"><cms:LocalizedLiteral ID="llNoHits" runat="server" /></td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
            <div id="membershipPaneOverlay" class="paneOverlay"></div>
            <div id="membershipPaneOverlayProgress" class="paneOverlayProgress"><img src="/Admin/img/progress.gif" alt="Progress" /></div>
        </div>
        <div class="pnlTabOverlay"></div>
    </asp:Panel>

    <asp:UpdatePanel ID="upnlActions" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
            <div id="pnlPopup" class="popup">
                <div class="popupMenuTop">
                    <div class="popupMenuTopBg">&nbsp;</div>
                    <div class="popupMenuTopLeftCorner">&nbsp;</div>
                    <div class="popupMenuTopRightCorner">&nbsp;</div>
                </div>
                <div class="popupMenu">
                    <div class="popupMenuLeftBg">&nbsp;</div>
                    <div class="popupMenuRightBg">&nbsp;</div>
                    <div class="popupMenuContent">
                        <a id="hlEdit" href="#"><img src="/Admin/Img/icons/shield.png" alt="Edit" /><span><cms:LocalizedLiteral ID="llEditMembership" runat="server" /></span></a>
                        <div class="horizontalDivider" style="margin-bottom: 3px; margin-top: 4px; margin-left: 27px; margin-right: 4px;"></div>
                        <asp:LinkButton ID="lbDeleteMembership" runat="server" OnClick="lbDeleteMembership_Click"><img id="imgDelete" runat="server" src="/Admin/Img/icons/cross.png" alt="Delete" /><span id="lblDelete" runat="server"><cms:LocalizedLiteral ID="llDeleteMembership" runat="server" /></span></asp:LinkButton>
                    </div>
                </div>
                <div class="popupMenuBottom">
                    <div class="popupMenuBottomBg">&nbsp;</div>
                    <div class="popupMenuBottomLeftCorner">&nbsp;</div>
                    <div class="popupMenuBottomRightCorner">&nbsp;</div>
                </div>
            </div>
            <input type="hidden" id="hidDeleteMembershipID" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>

    <script language="javascript">
        //<![CDATA[
        iLib.Dom.AddListener(window, "load", init);
        cms.Ajax.Init();
        cms.Ajax.AddEndRequestHandler(cms.Edit.HideTabOverlays);
        //]]>
    </script>
</asp:Content>
